<?php
error_reporting(0);
Workerman\Protocols\Http::sessionStart();

define('IN_IA', true);
ini_set('display_errors', 'on');
define('FILE_PATH', __DIR__ ."/..");
require_once FILE_PATH . '/include/function/common.func.php';
require_once FILE_PATH . '/include/function/pdo.func.php';


Workerman\Protocols\Http::header('Content-Type: text/html; charset=utf-8');

if(getgpc("token") == $_SESSION['login_token']){
	$username = getgpc("username");
	$password  = getgpc("password");
	$sql = "select name,`groups` from hf_mes_user where user='".$username."' and pwd='".strtoupper(md5($password))."';";
	$dp=pdo_fetchall($sql);

	if(count($dp)>0){
		$user_groups = $dp[0]['groups'];
		$sql = "select name from hf_mes_groups where id='$user_groups'";
		$dp_g = pdo_fetch($sql);
		// var_dump($sql,$dp_g);

		$_SESSION['IA_USER'] = $dp[0]['name'];
		$_SESSION['IA_GROUP'] = $dp_g['name'];
		$_SESSION['user_groups'] = $user_groups;
		echo "done";
	}
}


?>